<?php

namespace Apps\Common\Models;

/**
 * 美容院互动Model
 * @author     tanjinyun
 * @date        2016年1月19日
 * @version     2.0.2
 * @copyright   Copyright 2016 meelier.com
 */
class BeautyParlorInteractive extends \PhalconPlus\Database\Model
{

    /**
     *
     * @var integer
     */
    public $id;

    /**
     *
     * @var string
     */
    public $content;

    /**
     *
     * @var string
     */
    public $pics;

    /**
     *
     * @var integer
     */
    public $state;

    /**
     *
     * @var integer
     */
    public $bp_id;

    /**
     *
     * @var integer
     */
    public $user_id;

    public $addtime;


    /**
     * Initialize method for model.
     */
    public function initialize()
    {
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'beauty_parlor_interactive';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return BeautyParlorComment[]
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return BeautyParlorComment
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    /**
     * Independent Column Mapping.
     * Keys are the real names in the table and the values their names in the application
     *
     * @return array
     */
    public function columnMap()
    {
        return array(
            'id' => 'id',
            'content' => 'content',
            'pics' => 'pics',
            'state' => 'state',
            'bp_id' => 'bp_id',
            'user_id' => 'user_id',
            'addtime' => 'addtime',
        );
    }

    public function defaultColumns()
    {
        return [
            'id',
            'content',
            'pics',
            'state',
            'bp_id',
            'user_id',
            'addtime'
        ];
    }
    
    /**
     * 批量删除
     * @param $ids
     * @return bool
     */
    public static function updateState($idstr,$bp_id)
    {
        $sql = "update beauty_parlor_interactive set state = -1 where bp_id = {$bp_id} AND id in ({$idstr})";
        $model = new self;
        return $model->getWriteConnection()->execute($sql);
    }

}
